<template>
	<view style="padding-bottom: 150rpx;" v-if="pageShow">
		<view class="mainpadding flexbetween" style="background-color: #1ba95b;min-height: 170rpx;">
			<view class="">
				<view class="titletext sanshier xiaobai fonweight" v-if="dataAll.hx_status==1">待核销</view>
				<view class="titletext sanshier xiaobai fonweight" v-if="dataAll.hx_status==2">已核销</view>
				<view class="titletext sanshier xiaobai fonweight" v-if="dataAll.hx_status==3">已取消</view>
				<view class="titletext sanshier xiaobai fonweight" v-if="dataAll.hx_status==4">取消审核中</view>
			</view>
		</view>
		<view class="mainpadding_top ffffff">
			<view class="titletext sanshier fonweight">报名信息</view>
			<view class="flexbetween margin_top">
				<view class="strongtext">姓名：</view>
				<view class="strongtext">{{dataAll.username}}</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="strongtext">手机号：</view>
				<view class="strongtext">{{dataAll.mobile}}</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="strongtext">身份证号：</view>
				<view class="strongtext">{{dataAll.idcard}}</view>
			</view>
			<view class="ffffff mainpadding margin_top1" v-if="dataAll.activity.type==2">
				<view class="sanshis xiaohei fonweight">团队成员</view>
				<view class="flexleft" v-for="item in dataAll.activitybmuser" :key="item.id">
					<image :src="item.user.avatar_text" class="headimg" mode=""></image>
					<view class="ershiba strongtext">{{item.user.mobile}}</view>
				</view>
			</view>
		</view>
		<view class="mainpadding_top ffffff">
			<view class="flexbetween">
				<view class="shilitu margin_right2">
					<image :src="dataAll.activity.image_text" mode=""></image>
				</view>
				<view class="flexcolumn" style="width: 69%;align-items: flex-start;height: 160rpx;justify-content: space-between;">
					<view class="titletext xiaohei fonweight yhxk">{{dataAll.activity.name}}</view>
					<view class="strongtext xiaohui nofonweight">
						开始时间：{{dataAll.activity.bs_starttime_text}}</view>
					<view class="strongtext xiaohui nofonweight">
						截至时间：{{dataAll.activity.bs_endtime_text}}</view>
					<view class="sanshier xiaohong fonweight">￥{{dataAll.activity.price}}</view>
				</view>
			</view>
		</view>
		<view class="mainpadding_top ffffff flexcolumn" v-if="dataAll.hx_status==1">
			<view class="titletext sanshier fonweight">核销码</view>
			<uqrcode ref="uqrcode" canvas-id="qrcode" @click="ewmfn" v-bind:value="qrcodeurl"
				:options="{ margin: 10}" size="150">
			</uqrcode>
		</view>
		<view class="mainpadding_top ffffff">
			<view class="titletext sanshier fonweight">订单信息</view>
			<view class="flexbetween margin_top">
				<view class="strongtext">订单金额：</view>
				<view class="strongtext">￥{{dataAll.activity.price}}元</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="strongtext">优惠金额：</view>
				<view class="strongtext">￥{{dataAll.activityorder.coupon_price}}元</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="strongtext">实付金额：</view>
				<view class="strongtext">￥{{dataAll.activityorder.pay_price}}元</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="strongtext">创建时间：</view>
				<view class="strongtext">{{dataAll.createtime_text}}</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="strongtext">支付方式：</view>
				<view class="strongtext">{{returnpayway(dataAll.activityorder.pay_type)}}</view>
			</view>
		</view>
		<view class="gudingdb ffffff mainpadding" v-if="dataAll.hx_status==1 && dataAll.is_cancel">
			<view class="flexright">
				<view class="baibtn" @click="cancelitem(listid)">取消订单</view>
			</view>
		</view>
		<view class="gudingdb ffffff mainpadding" v-if="dataAll.hx_status==3 || dataAll.hx_status==2">
			<view class="flexright">
				<view class="baibtn" @click="delitem(listid)">删除订单</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				listid:"",
				dataAll: {},
				pageShow: false,
				qrcodeurl:"",
			}
		},
		onLoad(options) {
			this.listid = options.id
			this.getsystem()
		},
		onShow() {
			this.getDetail()
			
		},
		methods: {
			// 二维码点击预览图片
			ewmfn() {
				this.$refs.uqrcode.toTempFilePath({
					success: res => {
						console.log(res);
						var i = [res.tempFilePath]; //获取当前页面的轮播图数据
						//uniapp预览轮播图
						uni.previewImage({
							current: 0, //预览图片的下标
							urls: i //预览图片的地址，必须要数组形式，如果不是数组形式就转换成数组形式就可以
						})
					}
				});
			},
			getsystem(){
				httpRequest.request('/api/index/getConfigInfo', 'POST', {
				}, false, false, true).then(res => {
					this.qrcodeurl = res.data.activitydzp_url+"?hxid="+this.listid
				})
			},
			returnpayway(val) {
				if (val == 10) return "微信"
				if (val == 20) return "支付宝"
				if (val == 30) return "余额支付"
				if (val == 40) return "平台支付"
			},
			delitem(id) {
				httpRequest.modal('提示', '确认删除当前订单吗？', true, (res) => {
					if (res) {
						httpRequest.request('/api/user/activityBmDelete', 'POST', {
							id
						}, false, false, true).then(res => {
							httpRequest.toast(res.msg)
							if (res.code == 1) {
								setTimeout(()=>{
									uni.navigateBack(1)
								},1000)
							}
						})
					}
				})
			},
			cancelitem(id) {
				httpRequest.modal('提示', '确认取消当前订单吗？', true, (res) => {
					if (res) {
						httpRequest.request('/api/user/activityBmCancel', 'GET', {
							id
						}, false, false, true).then(res => {
							httpRequest.toast(res.msg)
							if (res.code == 1) {
								this.getDetail()
							}
						})
					}
				})
			},
			getDetail() {
				httpRequest.request('/api/user/activityBmDetail', 'GET', {
					id: this.listid
				}, false, false, true).then(res => {
					this.dataAll = res.data
					this.pageShow = true
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page{
		background-color: #f9f9f9;
	}
	.shilitu {
		width: 200rpx;
		height: 160rpx;
	
		image {
			width: 100%;
			height: 100%;
		}
	}
</style>
